home *** CD-ROM | disk | FTP | other *** search
-
- Listing 4
-
- ------------------------ globals.h ------------------------------
-
- #ifndef GLOBALS_H
- #define GLOBALS_H
-
- #ifdef DRIVER
- #define CLASS
- #define INIT (x) = x
- #else
- #define CLASS extern
- #define INIT (x)
- #endif
-
- CLASS char date[9] INIT("01-01090");
-
- #endif /* GLOBALS_H */
-
- ----------------------- file1.c ---------------------------------
-
- #define DRIVER
- #include "globals.h"
-
- main()
- {
- strcpy(date, "01-01-90");
- foo();
- puts(date);
- }
-
- ---------------------- file2.c ---------------------------------
-
- #include "globals.h"
-
- foo()
- {
- puts(date);
- strcpy(date, "02-02-90");
- puts(date);
- }
- ----------------------------------------------------------------
-
-